import java.util.Locale;

class Solution{
    public boolean isNumberAndCharacter(char ch){
        if(Character.isDigit(ch) || Character.isLetter(ch)) {
            return true;
        }
        return false;
    }

    public boolean isPalindrome(String s){
        s =s.toLowerCase();  //字符串中的字母转为小写
        int left = 0;
        int right = s.length() - 1;
        while(left < right){
            while(left < right && isNumberAndCharacter(s.charAt(left))){
                left++;
            }
            while(left < right && isNumberAndCharacter(s.charAt(right))){
                right--;
            }
            if(s.charAt(left) == s.charAt(right)){
                left++;
                right--;
            }else{
                return true;
            }
        }
        return false;
    }

}
public class Main {
    public static void main1(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.isPalindrome("abcdefg"));
        //用来运行代码

    }

    public static void main(String[] args) {

    }
}
